package com.hxs.email.controller;

import com.hxs.email.client.EduClient;
import com.hxs.email.pojo.entity.ScoreItem;
import com.hxs.email.task.GradeQueryTask;
import com.hxs.email.util.EmailSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class TestController {

    @Autowired
    EduClient eduClient;

    @Autowired
    EmailSender emailSender;

    @Autowired
    GradeQueryTask gradeQueryTask;
    @RequestMapping("/addUser")
    public String test(String sid, String password, String email){
//            gradeQueryTask.addUser(sid,password,email);
//        int term = LocalDate.now().getMonthValue() > 8 ? 1 : 2;
//        int currentYear = LocalDate.now().getYear();
//        int year = term == 1 ? currentYear : currentYear - 1;
//        term = term * term * 3;
//        eduClient.login("2024015861", "FUKENAnn12");
//        List<ScoreItem> studentScore = eduClient.getStudentScore(term,year);
//        StringBuilder gradeInfo = new StringBuilder();
//        for (ScoreItem scoreItem : studentScore) {
//            gradeInfo.append(scoreItem.getCourseName()).append(" ").append(scoreItem.getGrade()).append("\n");
//        }
//        emailSender.sendEmail("3599238616@qq.com",gradeInfo.toString());
        return "success";
    }
}
